Refactoring after bug issue. There was an if block that was in a foreach loop causing problems. Will need to refactor later to include custom exceptions.