code added to establish connection