checking for unique matrices