def METHOD_NAME(userid, limit, backid=None, nextid=None):
    state = [
        "SELECT pr.userid, pr.username, pr.config FROM watchuser wu"
        " JOIN profile pr ON wu.otherid = pr.userid"
        " WHERE wu.userid = %i" % (userid,)]
    if backid:
        state.append(" AND pr.username < (SELECT username FROM profile WHERE userid = %i)" % backid)
    elif nextid:
        state.append(" AND pr.username > (SELECT username FROM profile WHERE userid = %i)" % nextid)
    state.append(" ORDER BY pr.username")
    if backid:
        state.append(" DESC")
    state.append(" LIMIT %i" % limit)
    query = [{
        "userid": i[0],
        "username": i[1],
    } for i in d.execute("".join(state))]
    media.populate_with_user_media(query)
    return query[::-1] if backid else query