matrix checking works