added comments for program flow