implemented Nelder-Mead simplex optimization