refactored javascript into separate files