added check for null permissions