changed to work with optimizer