added option for retry attempts before flush