Fixed a small bug in real optimization