#the algorithm