refactoring to fix build errors (jshint)