refactor binary and add bash completion