add cli option, code cleanup