skeletal working version of the outer driver + minor refactoring