refactored to make more functions asynchronous, for tv4