Code for Lecture 18