implement algorithms