refactored driver.cc