Moved Options Parsing into function and clean up unused code