public static int findTab(final String title, final Connection conn) {
        int totalTabs = GUI.getTabbedPane().getTabCount();
        for (int i = 0; i < totalTabs; i++) {
            ChannelPanel channel = (ChannelPanel) GUI.getTabbedPane().getComponentAt(i);

            String channelName = channel.name;
            Connection c = channel.connection;
            String serverTitle = conn.title;
            if (conn == c && serverTitle.equals(title)) return i;
            if (channelName.equalsIgnoreCase(title) && conn == c) return i;
            if (conn == c && channelName.equalsIgnoreCase("")) return i;
        }
        return -1;
    }