Fix dimension check bug