renamed get to first
extracted matches helper to reduce duplicated code