refactored index code to use typdefed types so that we can switch to intrinsics later if we want