better deadlock prevention