modifications to fix similarity function