Fix invalid permission check