updated dmv to handle matrix as well.