fixed main() method for command line use