Included similarity function from old magic tool for future use