more complete middleware