improve error handling in CLI