make into middleware
add some comments to the readme