Avoid iterating over empty result