working with algorithm