fix invalid reference to null object