optimization in solving algorithm