Fixing a casting bug with similarity function normalization