algorithm is complete, phew