added initial and refactored solution