Fix WelshPowell algorithm