Add check for empty keygroup array (e.g., [[]]).