Working version of express middleware