Factorize chars fucntion