add middleware
add tests and middleware
add middleware and tests