refactor for jshint passed