fix code duplication, now in core