- Refactored algorithm