Added function with algorithm.