refactor: from printToConsole to StringWriter