Finished code for implementing level two