Modified the check and mate logic #2.
Fixed a bug in the check and mate logic #2.