working version for chars and charpairs