speedup attempt for charat
weird attempt to optimize visited