organizing js to work