divided up function into files, and added a command line arg option