Working tutorial code

(at least I hope it works)