fixed a bug in prediction routine