try to make data structures thread save by using a mutex