hist works
fix some bugs