problem 1
problem 2
problem 5
separating out helper functions