refactor javascripts