bug fixing
debuging the algorithm