minimize functions improved