internal build_index. closes #63
using 0-based indices