histroy storing and globaldata updation logic