better error handling of expired sessions and pagination