make so it handles empty result and error status correctly.