added check for permissions