Check if attribute exists before referencing