split code into separate files and got checkmate working