added connection handeling