Refactor JS into separate files