fix output buffering