Fixed bug to set the right permissions