Refactored into classes