Finished code for a5