code restructuring
added command line options