fixing maxlength bug