rewrite output handler