intial and refactored solution included