added savehistos func, finally