implemented most of the tutorial