code for dealing with result futures