added some locking