Tweaked code for week 3 submission