Remove undefined (and unused) $groups