fixed use middleware bug