refine the logic that detects array-like vs dictionary-like vs scalars values