add matchCharFun and some minor changes