Code for lecture 20