replace aglorithm