index out of bounds error for T set to highest value