checking in matrix