(bug) Fixed closure variable possible issue in history factory