fixed dereferenceing null pointer