Updated code to count matching rows, and return an error if the pad
isn't found.