convert empty or singular arrays to scalars