update and sort rules