added jshint and modified code based on results