update code to simplify rules