refactor the output to stderr