Edited for Coursera submission.