mostly working version.