Update to authenticate function