rewrite futures to remove explicit calls to continueWith