fixed that minpermdist could raise an excaption in some cases