add comment for algorithm function