Guard against null/undefined errors