reformatted the code,add comments and changed most log.info calls tolog.debug