fix getopts bug and joining bug