implemented the method for skipping comments in an iterative way