DETAILED SOLUTION