refactor, algorithm parameters extracted