Issue with same variable used twice