finished code I think