Fixed minimize function.