almost done with algo