Rewritten compare_fingerprints to be faster