fix permission check