Make icon safe to reference only when defined

'icon' isn't defined in some code paths, this minor edit makes it safe to reference it only when it's defined.