Implemented some methods in middleware