Trying to fix deadlock