started implementing value iteration. some code refactoring