More refactoring js