fixed possible deadlock