slowly but surely constructing promise function