partway through problem #2.  still want to go back and implement #1 using recursion as an alternate