Update implementation to reflect changes in Coursera. Refactor into class.