firstmatch should be called bestmatch