added jshint and refactored accordingly.