modified the way the directory detection works... its not foolproof,