Refactored in an object-oriented way