Start refactoring the JS