added getter and a controlled setter to the index variable