improve output and exit with error code when error found