added comments and fixed output messages