Fixed a logic issue, was referring to the wrong value when getting the cells index.