fixing auth and middleware