better output handling for command line