fixed if/else blocks for jslint
edited comment
adjusted code style and added comments
adjusted for jslint