fixed possible issue where row counts could mismatch