Refactor rebalance-command in the api