move connect procedure to background thread to prevent freezing