Part two of Coursera assignment