asynchronous loop to properly manage regular function calls