Can you shed some light on how your final code works?