fix null check with extra guard because it seems to behave differently on ci server