made it thread safe (basic)