updated code for command line parse (not stable yet)