get correct index