add is_array safety check