Check for None values before checking array length