Added validation of string length and array length