Changed variable scope to local.