Added code for lecture 9