Best way to use variables

Yes I do the same as you, they are only called when the user click on a tab button