add lock to the non atomic operation