Starting to remove global variable i