Class-based solution