Fixed a bug of the optimizer