Refactoring into separate .js files