Fixed key matching function