refactor javascript
clean up some javascript