fixed the Matches function