Added code from Project 2 to refactor for Project 3