def cases(chunk, local, remote_out, remote_in):
    if (chunk < local_end):
        return local(chunk)
    elif (chunk < remote_out_end):
        return remote_out((chunk - local_end))
    else:
        return remote_in((chunk - remote_out_end))
def cases(chunk, local, remote_out, remote_in):
    if (chunk < local_end):
        return local(chunk)
    elif (chunk < remote_out_end):
        return remote_out((chunk - local_end))
    else:
        return remote_in((chunk - remote_out_end))