replaced analytics with async function