Add a null check where necessary.