Added code from video lecture 7.