refctor tab management