refactoring to use getopts