attemp to fix permition bugs when the script is run from a privilaged directory