Randy Sargent's solution:
solution