added scope detection