fixing issue using local variable