Changed the router to a generic piece of middleware