null handling bug fix