added value iteration code