replaced NullPointerException with IllegalArgumentException