added comments and made first pass at code