simplify the adjustTitleWidth function