Fixed bug in rules engine