final refactor #4 using optparse