My lab 16 solution, objective outlined in the comments