Fix NPE, make method throw IllegalArgumentException