Redid architecture. Base class BaseAlgorithm -> NthElementAlgorithm