fix cmd.sh logic and reduce size