now handles nested rules and at rules