refactored update middleware with promise