change max to length max