type for idx and assert positive index