Fixed Bug in History

Refactored Code.