Fix Dice algorithm