switch to async function and set timeout for giving resolve of the whole function