Corrected mapping nesting logic