some refactoring & javascript WIP