Full JS refactoring