first complete, yet untested version