fixed permission check when checking subdirectories