working value function iteration