Add string length to error checking