with optimization algorithm