adding an optimize step