cleanup code of onStandardOutput and onStandardError