add update and sort function