Fixed the matches function