modified script to run from command line.