added comments and one flow chart