works for upstream
updated spireextract function