added mutex lock to update_piece method