replace NPE with IllegalArgumentException