Minimizing function.