Adding the solution from Alex's box.