fixing variables and the way were assigning indexes