Fixed bug in adding rule logic