added thread locks