move `middleware` to method