fix wrong permission check