trying challenge 3 - got it to work, though not sure how elegant this is