Added autobalance function.