improved structure
return index of first
move dt type to type.ml