adding scraps of code from coursera discussion boards