fixed connection code