improve handle thenable function