fixed race condition in connection go routine