Fixed code so that the grading test cases would pass (3 tests previously did not). Still need to refactor!