Code from lecture 11 on Nov 13