Fix bug in authorize