fix bugs and add option in the command line