Optimizing code structure with async