added the permissions check