added comments and a few changes