Refactoring: finished algorithm in enumerate().