Improve error reporting in CountCommand