rewrite tail