refactory with async