Fixed a typo where the wrong index was used