Finished code for #3