changed scopes to codetype; simplified resource check