JS REFACTOR