Add helper functions for saving history