NullPointerException bug fix