optimizing tab handling