ticket 3: added middleware