using sqlite to improved rules matching