looks just like sync code, but its async.