devised a much better way to set active tab