initial (somewhat) working version