Algorithm functioning