refactor/organize js