Added basic logic for connection