added retry and logging