Solution

Ready for code review.