done sceleton of the algorithm