reorganize code related to package command