move trimNested() down later in the steps