add explicit check for array before trying Array.unobserve