work in progress, initial working version