added jslint check and refactored to pass the test