more js refactor