fixing terminate connection