Trying to solve dead-lock