ticket:3 implemented middleware