Start of js  refactoring