Annotates matchRows function
Abstracts logic into separate functions