Add check for max length to avoid client crashes