Added algorithm in comments.