refector middleware