my attempt at the coursera homework