added middleware to store db queries