Done debuging both algotrithms