added while handling
added comments and for