refactoring the javascript + linting