diff --git a/lib/plum/hpack/context.rb b/lib/plum/hpack/context.rb
index <HASH>..<HASH> 100644
--- a/lib/plum/hpack/context.rb
+++ b/lib/plum/hpack/context.rb
@@ -22,7 +22,15 @@ module Plum
       end
 
       def fetch(index)
-        STATIC_TABLE[index - 1] || @dynamic_table[index - STATIC_TABLE.size - 1] or raise HPACKError.new("invalid index: #{index}")
+        if index == 0
+          raise HPACKError.new("index can't be 0")
+        elsif index <= STATIC_TABLE.size
+          STATIC_TABLE[index - 1]
+        elsif index <= STATIC_TABLE.size + @dynamic_table.size
+          @dynamic_table[index - STATIC_TABLE.size - 1]
+        else
+          raise HPACKError.new("invalid index: #{index}")
+        end
       end
 
       def evict
diff --git a/lib/plum/hpack/decoder.rb b/lib/plum/hpack/decoder.rb
index <HASH>..<HASH> 100644
--- a/lib/plum/hpack/decoder.rb
+++ b/lib/plum/hpack/decoder.rb
@@ -60,11 +60,7 @@ module Plum
         # | 1 |        Index (7+)         |
         # +---+---------------------------+
         index = read_integer!(str, 7)
-        if index == 0
-          raise HPACKError.new("index can't be 0 in indexed heaeder field representation")
-        else
-          fetch(index)
-        end
+        fetch(index)
       end
 
       def parse_indexing!(str)
hpack: decoder: refactor