Code for lecture 19