generate_history refined