Rewrote some parts of tutorial exercise 3