changed from middleware to log handler