middleware approach