Modify rebalance-command and refactor