add cli options; fix logic