Properly handle query.offset and query.limit