getting correct index