added routes and refactored them to use events to trigger them.