Add retries in functional api