js refactor work