rewrite stdout handler