Algorithm fixed
Updated documentation