moved authentication process to a single function, now in the auth directory