fix error in .then
middleware function
use req instead of fields for middleware
better sequence