add null-pointer checks