Added handling of empty result sets