added safeguard for a case when the future is done before the result is set