Changed auth code to simplify it a bit