Review order of conditions to optimize performance

If we do not need authorization, there is no need to perform a lookup (with an order_by) which could have a cost not negligible.
Merge pull request #499 from mtparet/patch-1

Review order of conditions to optimize performance