modified version for authentication, no compiling so far