keep position of identifier in for loop when optimizing it to a while loop