setting currentIndex as a public variable