fix bug in auto-balance expression