modified to check for permission on contents