refactor class and working check /checkmate logic