Fix detection of primary