add comments for algorithm