cleanup js
refactor lots of the js