Complete code with corrected comments