rewrite JS to support new reporting system