Add code given in lecture 3.