Refactoring and putting in comments - working solution all test passing