Implement filter and state query url

Change the first `if` to just `if (offset)` or it will never run the `else`.