fixed unitialised currentIndex