Frontend js refactoring