checkmate is working for checking if king can get out of it or not, i think
added code from master