Some litte changes on the optimize methode