Refactoring negamax