adding documention to algorithm