Add history logic