Refactored in OOP style.