Converted middleware to standard style