Fixing deadlock issue