correcting null pointer reference