working version, also some repackaging