Fixes issue in applying permissions