added comments for while loop