better organization of auth code