modified the file to add history function