Refactor cli