add pairs_encode method