added middleware