organized javascript

still could make functions better