Its missing a check for $out.
RP needs to be ignored and forced as primary if $out is used