more robust device type detection