updated the animation function
Correcting the value iteration