jshinted code, added some comments