This function is copied from folly, so leave it there?