skeleton of the algorithm done