Refactor Javascript now concepts are understood (again)