YELLOW (refactoring). organized some methods and created a method for when to throw illegalArgumentException.