Fix NullPointerException issue