Refactor JS to one file