fix null pointer exception when getting an empty result set