Refactored code to use actual classes