refactored to accept one more commandline parameter