refactoring - moving things into separate js files