Moved matching function to utilities