Make isLegalNet a free function