Refactor the maximum term length here out into a constant, and/or add it as an argument with a default value.