removed unnecessary if statement
fixed bad pass of x(:,:) to set_primaries