Splitting and joining arrays