more generic code; calc tot background; calc prelim R correctly