prototype algorithm working