add minimum length check, remove unnecessary maximum length check