tutorial was updated since last I worked on this. Functions are now in separate module