two-part approach implemented; code commented