refactor, use transposition table