more code refactoring and using the optparse
remove blank line and useless code