move some logic back to core/utils