Comments added for clarity.