simplify addchar code