No idea what I changed.
Added codes for the optimization.