client: fix retry logic