refactoring code jslint compliant