Refactor cli module