added check for empty result sets