added sanity check on input rows