NPE bug fix