refactored some javascript into seperate files