improved rule parser