Here's the end of the code I wrote.