This looks expensive.  Can we cache the result so that this function can be called multiple times (as it probably will be)?