refactor to pass jshint tests