reduced wait time; added reconnect after write fail