maxmin strategy
refactored duplication from algorithm
algorithm for minmax