working problem 4, and problem 3 that needs to be more efficient