Adding logging and retry on errors