refactor the join cmd into its own func