utility js refactor