def METHOD_NAME(service_id, older_than=None, page_size=None):
    if page_size is None:
        page_size = current_app.config["PAGE_SIZE"]
    filters = [InboundSms.service_id == service_id]
    if older_than:
        older_than_created_at = db.session.query(InboundSms.created_at).filter(InboundSms.id == older_than).as_scalar()
        filters.append(InboundSms.created_at < older_than_created_at)
    query = InboundSms.query.filter(*filters)
    return query.order_by(desc(InboundSms.created_at)).paginate(per_page=page_size).items