prevent getting stuck if dir() returns itself