Update nested elements code to handle slices and maps