written successful similarity algorithm