debug for algorithm phase two