in the future maybe this function should be in core/generic?