WIP refactor js