Fixed the value function ...

… with some where definitions.