refactored route dispatcher to use express middleware
updated version