refactor + make jshint pass