Added logic to run from command line.