refactors javascript