the resolve method should be performed async by using setTimeout(resolve, 0)