js refactorings