connection handling improved