adds a safe-guard to avoid deadlocks