refactor/organize js
clean up code