avoiding null pointer errors

Change-Id: I596e996aec7e44e4c6276652f2b9180d29102d8a