fixed a little bug: after empty the array I have to reinitialize the currentindex