refactors javascript into separate files