Fixed bug in authorization logic