fix auth function