wrapper function for minimization