My solution, which seems a little naive.