Fixed authenticatication function

An error was introduced in the last commit that caused auth to fail