add null-pointer check