cleaning up connection code