added sample code from Coursera