typo, initilized i as int instead of var.