fix for before middleware