Updated Code from lecture 4