Refactor

Refactored in OOP style.