Completed matching function