Fix empty result set error