added sampling checking for matrices