only calculate optimum parameters once