put ndim check in utils