attach scope to file in smarter fashion