Fixing this command line script - haven't used it in a while; wasn't working