thread safe and better scope managment