added middleware handler