Adding logging and retry