Fixing bug with directory where permission is overwrote