migrate js to separate file