maxChars now is a function