Refactor to have JS in different files.