Refactor + make regular middleware