Add null checker to avoid crash