Adding a check to avoid an potential crash.