partial solution to rulesApply...but don't quite understand why it's working; just followed compiler instructions