partial rewrite of doreport