code to insert userhistory