fix spdt algorithm