Adjusted version
Refactored class hierarchy