Added: Refactored solution