added residual checking to value iteration