Improve expand_history.rb