working on middleware