Refactored javascript into seperate file