alignment with similarity function