simple and complex algorithm