fixed bug: dim(bac)>n*m