rewwriting to be asyncronous