Added detection of checkmate