Implement history logic correctly