Finished code according to tutorial