Refactorying code using jshint