add delete function for user history, refine code