Fixed null ptr dereference