Small refactoring on the JS.