refactor: use atomic operation.