fixed some bugs in SelectSubMatrix