turned on and fixed middleware