Refactor JS into smaller files