initial working version, much TODO