Alternatives to activate a new tab?

I have removed the selectWindow function where possible as it doesn’t work reliable (randomly stops continuation of the program).
But the function is still required where a button press opens a new tab to switch to that new tab. Currently I do this with selectWindow tab=1 but as it is selectWindow it randomly stops the code execution.
Is there any other approach to switch to a new tab as active one not using selectWindow?