finished code for ex1, still need the writeup