Added comments for code clarification.