refactor cli.js