Fix off-by-one in prefix check