can now be used as middleware like in issue #4