Changed global to local var