created separate function for endgame + fixed bug alpha-beta