fig bug in dynamic programming.

It has given wrong results for models with more than 256 states!