Refactoring of Middleware's before/after_block