automatic scope detection