code refactoring

made compatible with jshint