sketch the algorithm