need to check for 1 less than max so null character can be added