Refactor nodejs to handle command line arguments