fix inappropriate locking sequenece