testing the algorithm