Correctly count rows for error message