update code
add lock guard