Added code for lecture 6