some refactoring. improve the driver.