added ability to choose maximization or minimization
added ability to choose maximization or minimization