bugfix:  use lock