Fixed bug with pending connection

I forgot everything i did with this code.