finally made stuff threadsafe