added check to see if index is 0