move some logic for packages inside service.