Refactored to comply with DIP principle.