fixed broken endindex