Ensures thread safety