Added code from lecture