Code from lecture.