Fix NullPointerException bug