fix checkmate. need to finish tests and refactor