further refactor of cmd_folder