checkmate function fixed