improved rule handling