fixed a few more things to make it as close to the example as possible