Fix bug with duplicate variable