Fixed exception being thrown on index() method 

index() method tries to access empty versions array. 

Added check to see if the version exists in the versions array.