Added algorithm used on the comments