NEW updated middleware to be express 4.x compatible