Before refactoring algorithm to make it faster.