properly resolve promises