added locks code