Fixing empty result array on error