fix bugs and finish histData