Nelder Mead error fixed