redefined similarity function