fixed some value iteration code. this code needs a lot of tune up...