improve recursive type detection