Fix offset pos bug

When they are more than two pages, the pos variable keeps the same value.