fix #282: index checking for matrices