check rowcount before trying to fetch rows