Fixing scope bug between patterns and resource.