fix checking for the right var and move check inside if vars_data