Checkmate function finally appears to be working. Needs one more subroutine added later on though.