safer code (if one thread crashes)